package com.muyu.danmo.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.danmo.domain.DanmoAssociationType;
import com.muyu.danmo.domain.DanmoInformationMap;
import com.muyu.danmo.mapper.DanmoAssociationTypeMapper;
import com.muyu.danmo.mapper.DanmoInformationMapMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.danmo.mapper.DanmoInformationMapTitleMapper;
import com.muyu.danmo.domain.DanmoInformationMapTitle;
import com.muyu.danmo.service.IDanmoInformationMapTitleService;

/**
 * 相关星图标题Service业务层处理
 * 
 * @author kunzong
 * @date 2024-12-09
 */
@Service
public class DanmoInformationMapTitleServiceImpl extends ServiceImpl<DanmoInformationMapTitleMapper, DanmoInformationMapTitle> implements IDanmoInformationMapTitleService
{
    @Autowired
    private DanmoInformationMapTitleMapper danmoInformationMapTitleMapper;

    @Autowired
    private DanmoInformationMapMapper danmoInformationMapMapper;

    /**
     * 查询相关星图标题
     * 
     * @param id 相关星图标题主键
     * @return 相关星图标题
     */
    @Override
    public DanmoInformationMapTitle selectDanmoInformationMapTitleById(Long id)
    {
        DanmoInformationMapTitle danmoInformationMapTitle = danmoInformationMapTitleMapper.selectDanmoInformationMapTitleById(id);
        danmoInformationMapTitle.setViews(danmoInformationMapTitle.getViews() + 1);
        danmoInformationMapTitleMapper.updateDanmoInformationMapTitle(danmoInformationMapTitle);
        return danmoInformationMapTitle;
    }

    /**
     * 查询相关星图标题列表
     * 
     * @param danmoInformationMapTitle 相关星图标题
     * @return 相关星图标题
     */
    @Override
    public List<DanmoInformationMapTitle> selectDanmoInformationMapTitleList(DanmoInformationMapTitle danmoInformationMapTitle)
    {
        return danmoInformationMapTitleMapper.selectDanmoInformationMapTitleList(danmoInformationMapTitle);
    }

    /**
     * 新增相关星图标题
     * 
     * @param danmoInformationMapTitle 相关星图标题
     * @return 结果
     */
    @Override
    public int insertDanmoInformationMapTitle(DanmoInformationMapTitle danmoInformationMapTitle)
    {
                danmoInformationMapTitle.setInformationId(10L);
                danmoInformationMapTitle.setViews(0L);
                danmoInformationMapTitleMapper.insertDanmoInformationMapTitle(danmoInformationMapTitle);
                List<DanmoInformationMap> danmoInformationMapList = danmoInformationMapTitle.getDanmoInformationMapList();
                if (danmoInformationMapList != null || !danmoInformationMapList.get(0).getName().equals("")) {
                    for (DanmoInformationMap danmoInformationMap : danmoInformationMapList) {
                        danmoInformationMap.setMapTitleId(danmoInformationMapTitle.getId());
                        danmoInformationMapMapper.insertDanmoInformationMap(danmoInformationMap);
                    }
                }
        return 0;
    }

    /**
     * 修改相关星图标题
     * 
     * @param danmoInformationMapTitle 相关星图标题
     * @return 结果
     */
    @Override
    public int updateDanmoInformationMapTitle(DanmoInformationMapTitle danmoInformationMapTitle)
    {
        return danmoInformationMapTitleMapper.updateDanmoInformationMapTitle(danmoInformationMapTitle);
    }

    /**
     * 批量删除相关星图标题
     * 
     * @param ids 需要删除的相关星图标题主键
     * @return 结果
     */
    @Override
    public int deleteDanmoInformationMapTitleByIds(Long[] ids)
    {
        return danmoInformationMapTitleMapper.deleteDanmoInformationMapTitleByIds(ids);
    }

    /**
     * 删除相关星图标题信息
     * 
     * @param id 相关星图标题主键
     * @return 结果
     */
    @Override
    public int deleteDanmoInformationMapTitleById(Long id)
    {
        return danmoInformationMapTitleMapper.deleteDanmoInformationMapTitleById(id);
    }
}
